package com.tedu.bill.demo4;

import java.io.*;

/**
 * Author：毕龙
 * Date: 2024/5/28 9:24
 */
public class TestFile4 {
    public static void main(String[] args) throws IOException {
        //创建字节流
        FileInputStream fis = new FileInputStream("day14/src/test.txt");
        //转化流 将字节流转化为字符流
        Reader reader = new InputStreamReader(fis);
        //将字符流转化为过滤流
        BufferedReader br = new BufferedReader(reader);


        //创建字符输出流
        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("day14/src/test1.txt"));
        //创建缓冲流
        BufferedWriter bw = new BufferedWriter(osw);

        //获取系统当前的时间戳
        long t1 = System.currentTimeMillis();
        String str;
        while ((str = br.readLine()) != null){
            //在控制台中输出
            System.out.print(str);
            //复制到另一个文件中
            bw.write(str);
            bw.newLine();
        }
        long t2 = System.currentTimeMillis();
        //获取时间
        System.out.println(t2-t1);

        //刷新
        //bw.flush();

        //关闭流
        bw.close();
        osw.close();
        br.close();
        reader.close();
        fis.close();



    }
}
